<?php

namespace backend\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\GraduationAudit;

/**
 * GraduationAuditSearch represents the model behind the search form of `backend\models\GraduationAudit`.
 */
class GraduationAuditSearch extends GraduationAudit
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['ID', 'XXID', 'BYND', 'ZYGS', 'BYRS'], 'integer'],
            [['XXMC', 'JBRXM', 'JBRDH', 'CJSJ', 'GXSJ', 'SHZT', 'SJYJYJ', 'SJYJRQ', 'ZZQYYR', 'ZZQYYRQ', 'QJYTYJ', 'QJYTRQ', 'QJYTJYR', 'QJYTJYRQ'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = GraduationAudit::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'ID' => $this->ID,
            'XXID' => $this->XXID,
            'BYND' => $this->BYND,
            'ZYGS' => $this->ZYGS,
            'BYRS' => $this->BYRS,
            'CJSJ' => $this->CJSJ,
            'GXSJ' => $this->GXSJ,
            'SJYJRQ' => $this->SJYJRQ,
            'ZZQYYRQ' => $this->ZZQYYRQ,
            'QJYTRQ' => $this->QJYTRQ,
            'QJYTJYRQ' => $this->QJYTJYRQ,
        ]);

        $query->andFilterWhere(['like', 'XXMC', $this->XXMC])
            ->andFilterWhere(['like', 'JBRXM', $this->JBRXM])
            ->andFilterWhere(['like', 'JBRDH', $this->JBRDH])
            ->andFilterWhere(['like', 'SHZT', $this->SHZT])
            ->andFilterWhere(['like', 'SJYJYJ', $this->SJYJYJ])
            ->andFilterWhere(['like', 'ZZQYYR', $this->ZZQYYR])
            ->andFilterWhere(['like', 'QJYTYJ', $this->QJYTYJ])
            ->andFilterWhere(['like', 'QJYTJYR', $this->QJYTJYR]);

        return $dataProvider;
    }
}
